/**
 * Create by CaoWenjian
 *
 * @copyRight: 2018
 **/
package com.bjboot.caocao.common.utils;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 *@Description 分页的数据控制类
 *@Author 操文健
 *@Date 2018-09-11 下午7:17
 *@Version 1.0
 **/
public class Query extends LinkedHashMap<String, Object> implements Serializable {
    private static final long serialVersionUID = -4377468720659548445L;

    private int offset;
    // 每页条数
    private int limit;

    public Query(Map<String, Object> params) {
        this.putAll(params);
        // 分页参数
        this.offset = Integer.parseInt(params.get("offset").toString());
        this.limit = Integer.parseInt(params.get("limit").toString());
        this.put("offset", offset);
        this.put("page", offset / limit + 1);
        this.put("limit", limit);
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.put("offset", offset);
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }
}
